package thread;

/**
 * Title：
 * Description：
 * Created by Myth on 4/17/2017.
 */
public class SaleTickets implements Runnable {
    private String name;
    private int ticketNum = 6; //多个Thread启动同一个该线程类，共享此数目

    public SaleTickets(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            if (ticketNum > 0) {
                System.out.println("卖了一张票：剩余  " + ticketNum--);
            }
        }
    }
}
